//Flyweight（享元模式）
//Flyweight模式通过共享对象来最小化内存使用。在Go语言中，可以使用Map来实现享元模式。

package flyweight

type Flyweight struct {
	SharedField string
}

var flyweights map[string]*Flyweight = make(map[string]*Flyweight)

func GetFlyweight(key string) *Flyweight {
	if _, ok := flyweights[key]; !ok {
		flyweights[key] = &Flyweight{}
	}
	return flyweights[key]
}
